using System;
using System.Collections.Generic;

using Jeffrey.XFramework;
using Jeffrey.XFramework.XManager;

namespace Jeffrey.XProcess
{
    public class MemoryUriContainer : UriContainer
    {
        public MemoryUriContainer()
        {
            m_PendingUris = new Queue<String>();
        }

        public override Int32 UriCounter
        {
            get { return m_PendingUris.Count; }
        }

        protected override void Release()
        {
            m_PendingUris.Clear();
        }

        protected override String innerGetNext()
        {
            if (m_PendingUris.Count > 0)
                return m_PendingUris.Dequeue();
            else
                return null;
        }

        protected override void innerSchedule(String uri)
        {
            m_PendingUris.Enqueue(uri);
        }

        internal Queue<String> m_PendingUris;
    }
}
